﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.SetTemplateAndKeywords.CUISetTemplateAndKeywordsDialog
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using EngineeringInternalExtension;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Windows.Forms.Layout;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.Olp;
using Tecnomatix.Engineering.Olp.CustomizedTemplate;
using Tecnomatix.Engineering.Ui;


namespace DnProcessSimulateCommands.SetTemplateAndKeywords;

internal class CUISetTemplateAndKeywordsDialog : TxForm
{
  private TxOlpDownloadTemplateServices m_templateServices;
  private TxRobot m_robot;
  private List<ITxRoboticOperation> m_operations = new List<ITxRoboticOperation>();
  private CUISetTemplateAndKeywordsCopyDialog m_copyDLG;
  private List<Control> m_robotControls = new List<Control>();
  private List<Control> m_operationControls = new List<Control>();
  private int m_maxRobotLabelWidth;
  private int m_maxOperationLabelWidth;
  private int m_realY;
  private string m_templateName = "";
  private IContainer components;
  private Button Copy_button;
  private Button OKButtonCtrl;
  private Button Close_button;
  private Label label1;
  private ComboBox TemplateCombo;

  private List<Control> RobotControls
  {
    get => this.m_robotControls;
    set => this.m_robotControls = value;
  }

  private List<Control> OperationControls
  {
    get => this.m_operationControls;
    set => this.m_operationControls = value;
  }

  internal CUISetTemplateAndKeywordsDialog() => this.InitializeComponent();

  private void Close_button_Click(object sender, EventArgs e) => ((Form) this).Close();

  private void Copy_button_Click(object sender, EventArgs e)
  {
    List<string> stringList = new List<string>();
    foreach (object obj in this.TemplateCombo.Items)
      stringList.Add(obj as string);
    this.m_copyDLG = new CUISetTemplateAndKeywordsCopyDialog(this.m_robot, this.m_operations);
    ((Form) this.m_copyDLG).FormClosing += new FormClosingEventHandler(this.copyDLG_FormClosing);
    ((Control) this.m_copyDLG).Show();
  }

  private void copyDLG_FormClosing(object sender, EventArgs e)
  {
    ITxRoboticOperation selecetdOperation = this.m_copyDLG.m_selecetdOperation;
    this.m_copyDLG = (CUISetTemplateAndKeywordsCopyDialog) null;
    if (selecetdOperation == null)
      return;
    TxRoboticParam parameter = selecetdOperation.GetParameter("OLP_XML_DOWNLOAD_TEMPLATE");
    if (parameter == null || !(parameter is TxRoboticStringParam))
      return;
    string str = (parameter as TxRoboticStringParam).Value;
    List<ITxRoboticOperation> collection = new List<ITxRoboticOperation>((IEnumerable<ITxRoboticOperation>) this.m_operations);
    this.m_operations.Clear();
    this.m_operations.Add(selecetdOperation);
    this.TemplateCombo.SelectedItem = (object) str;
    this.TemplateCombo.SelectedText = str;
    this.RebuildDialog();
    this.m_operations.Clear();
    this.m_operations.AddRange((IEnumerable<ITxRoboticOperation>) collection);
  }

  private void OK_button_Click(object sender, EventArgs e)
  {
    Cursor current = Cursor.Current;
    Cursor.Current = Cursors.WaitCursor;
    TxApplication.ActiveUndoManager.StartTransaction();
    string text = this.TemplateCombo.Text;
    string str1 = "";
    if (this.m_operations.Count == 0)
    {
      TxRoboticParam instanceParameter1 = this.m_robot.GetInstanceParameter("OLP_XML_DOWNLOAD_TEMPLATE");
      if (instanceParameter1 != null && instanceParameter1 is TxRoboticStringParam)
        str1 = (instanceParameter1 as TxRoboticStringParam).Value;
      if (str1 != text)
      {
        if (this.TemplateCombo.Text == "")
          this.m_robot.RemoveInstanceParameter("OLP_XML_DOWNLOAD_TEMPLATE");
        else
          this.m_robot.SetInstanceParameter((TxRoboticParam) new TxRoboticStringParam("OLP_XML_DOWNLOAD_TEMPLATE", text));
        this.m_templateServices.ClearTemplateKeywords(str1, this.m_robot);
        foreach (object instanceParameter2 in this.m_robot.GetAllInstanceParameters())
        {
          string type = (instanceParameter2 as TxRoboticParam).Type;
          if (type.Contains("OLP_SELECTED_PROGRAM_TEMPLATE_"))
            this.m_robot.RemoveInstanceParameter(type);
        }
      }
    }
    else
    {
      List<string> stringList = new List<string>();
      foreach (ITxRoboticOperation operation in this.m_operations)
      {
        string str2 = "";
        TxRoboticParam parameter = operation.GetParameter("OLP_XML_DOWNLOAD_TEMPLATE");
        if (parameter != null && parameter is TxRoboticStringParam)
          str2 = (parameter as TxRoboticStringParam).Value;
        if (str2 != text)
        {
          if (this.TemplateCombo.Text == "")
            operation.RemoveParameter("OLP_XML_DOWNLOAD_TEMPLATE");
          else
            operation.SetParameter((TxRoboticParam) new TxRoboticStringParam("OLP_XML_DOWNLOAD_TEMPLATE", text));
          if (!stringList.Contains(str2) && str2 != "")
            stringList.Add(str2);
          this.m_templateServices.ClearTemplateKeywords(str2, operation);
        }
        foreach (Control operationControl in this.OperationControls)
          this.SetOperationParameters(operationControl, operation);
      }
      if (stringList.Count > 0)
        this.m_templateServices.ClearTemplateKeywords(stringList, this.m_robot);
    }
    foreach (Control robotControl in this.RobotControls)
      this.SetRobotParameters(robotControl);
    TxApplication.ActiveUndoManager.EndTransaction();
    ((Form) this).Close();
    Cursor.Current = current;
  }

  private void SetRobotParameters(Control ctrl)
  {
    if (ctrl is TxNumericEditBoxCtrl)
    {
      TxNumericEditBoxCtrl numericEditBoxCtrl = ctrl as TxNumericEditBoxCtrl;
      if (numericEditBoxCtrl.ValueType == 4)
      {
        this.m_robot.SetInstanceParameter((TxRoboticParam) new TxRoboticDoubleParam(((Control) numericEditBoxCtrl).Name, numericEditBoxCtrl.Value));
      }
      else
      {
        if (numericEditBoxCtrl.ValueType != 3)
          return;
        this.m_robot.SetInstanceParameter((TxRoboticParam) new TxRoboticIntParam(((Control) numericEditBoxCtrl).Name, (int) numericEditBoxCtrl.Value));
      }
    }
    else
      this.m_robot.SetInstanceParameter((TxRoboticParam) new TxRoboticStringParam(ctrl.Name, ctrl.Text));
  }

  private void SetOperationParameters(Control ctrl, ITxRoboticOperation operation)
  {
    if (ctrl is TxNumericEditBoxCtrl)
    {
      TxNumericEditBoxCtrl numericEditBoxCtrl = ctrl as TxNumericEditBoxCtrl;
      if (numericEditBoxCtrl.ValueType == 4)
      {
        operation.SetParameter((TxRoboticParam) new TxRoboticDoubleParam(((Control) numericEditBoxCtrl).Name, numericEditBoxCtrl.Value));
      }
      else
      {
        if (numericEditBoxCtrl.ValueType != 3)
          return;
        operation.SetParameter((TxRoboticParam) new TxRoboticIntParam(((Control) numericEditBoxCtrl).Name, (int) numericEditBoxCtrl.Value));
      }
    }
    else
      operation.SetParameter((TxRoboticParam) new TxRoboticStringParam(ctrl.Name, ctrl.Text));
  }

  private void TemplateCombo_SelectedValueChanged(object sender, EventArgs e)
  {
    if (!(this.m_templateName != this.TemplateCombo.Text))
      return;
    this.RebuildDialog();
  }

  private void RebuildDialog()
  {
    this.m_templateName = this.TemplateCombo.Text;
    ((Control) this).MaximumSize = new Size(0, 0);
    ((Control) this).MinimumSize = new Size(0, 0);
    this.RobotControls.Clear();
    this.OperationControls.Clear();
    for (int index = ((Control) this).Controls.Count - 1; index > 4; --index)
      ((Control) this).Controls.RemoveAt(index);
    this.InitSizes();
    this.RobotControls = this.m_templateServices.GetRobotKeyWordsControls(this.TemplateCombo.Text);
    if (this.m_operations.Count > 0)
      this.OperationControls = this.m_templateServices.GetOperationKeyWordsControls(this.TemplateCombo.Text, this.m_operations[0]);
    if (this.RobotControls.Count > 0)
    {
      this.AddGroupToDialog(CApSetTemplateAndKeywordsStringTable.RobotKeywords, this.RobotControls, 3, ref this.m_maxRobotLabelWidth);
      this.UpdateRobotControls();
      this.AddDelegateToControls(this.RobotControls);
    }
    if (this.OperationControls.Count > 0)
    {
      this.AddGroupToDialog(CApSetTemplateAndKeywordsStringTable.OperationKeywords, this.OperationControls, 40, ref this.m_maxOperationLabelWidth);
      this.UpdateOperationControls();
      this.AddDelegateToControls(this.OperationControls);
    }
    if (this.m_realY == 35)
      this.m_realY = 0;
    else
      this.m_realY -= 35;
    this.FixedButtonsAndDilaog();
    this.CheckRequiredDialogFields();
  }

  private void CUISetTemplateAndKeywordsDialog_Resize(object sender, EventArgs e)
  {
    if (this.RobotControls.Count <= 0 && this.OperationControls.Count <= 0)
      return;
    Size size1 = this.label1.Size;
    int width1 = size1.Width;
    size1 = this.TemplateCombo.Size;
    int width2 = size1.Width;
    int width3 = width1 + width2 + 5;
    int num = width3 - this.m_maxRobotLabelWidth - 17;
    int width4 = width3 - this.m_maxOperationLabelWidth - 17;
    foreach (Control robotControl in this.RobotControls)
    {
      Control control = robotControl;
      int width5 = num;
      size1 = robotControl.Size;
      int height = size1.Height;
      Size size2 = new Size(width5, height);
      control.Size = size2;
    }
    foreach (Control operationControl in this.OperationControls)
      operationControl.Size = new Size(width4, operationControl.Size.Height);
    foreach (Control control in (ArrangedElementCollection) ((Control) this).Controls)
    {
      if (control is GroupBox)
        control.Size = new Size(width3, control.Size.Height);
    }
  }

  private void CUISetTemplateAndKeywordsDialog_Activated(object sender, EventArgs e)
  {
    if (this.m_copyDLG == null)
      return;
    ((Form) this.m_copyDLG).Activate();
  }

  private void control_Leave(object sender, EventArgs e) => this.CheckRequiredDialogFields();

  private void control_Enter(object sender, EventArgs e) => this.CheckRequiredDialogFields();

  private void txObjComboBoxCtrl_Picked(object sender, TxObjComboBoxCtrl_PickedEventArgs args)
  {
    this.CheckRequiredDialogFields();
  }

  private void txObjEditBoxCtrl_Picked(object sender, TxObjEditBoxCtrl_PickedEventArgs args)
  {
    this.CheckRequiredDialogFields();
  }

  private void txObjComboBoxCtrl_SelectionChanged(object sender, EventArgs e)
  {
    this.CheckRequiredDialogFields();
  }

  private void comboBoxCtrl_SelectedIndexChanged(object sender, EventArgs e)
  {
    this.CheckRequiredDialogFields();
  }

  private void textBox_TextChanged(object sender, EventArgs e) => this.CheckRequiredDialogFields();

  private void txNumericEditBoxCtrl_KeyChanged(object sender, EventArgs e)
  {
    TxNumericEditBoxCtrl numericEditBoxCtrl = sender as TxNumericEditBoxCtrl;
    double result = 0.0;
    if (double.TryParse(((Control) numericEditBoxCtrl).Text, out result))
    {
      if (result > numericEditBoxCtrl.UpperBound || result < numericEditBoxCtrl.LowerBound)
        this.OKButtonCtrl.Enabled = false;
      else
        this.CheckRequiredDialogFields();
    }
    else
      this.OKButtonCtrl.Enabled = false;
  }

  public virtual void OnInitTxForm()
  {
    base.OnInitTxForm();
    this.InitSizes();
    this.m_realY = 0;
    this.FixedButtonsAndDilaog();
    this.InitRobot();
    if (!this.InitDownloadTemplateServices())
      this.OpenCustomizedCommandXMLCheckerCmd();
    else
      this.InitTemplateCombo();
  }

  private void FixedButtonsAndDilaog()
  {
    Size size1 = ((Form) this).Size;
    int width1 = size1.Width;
    size1 = ((Form) this).Size;
    int height1 = size1.Height + this.m_realY;
    ((Form) this).Size = new Size(width1, height1);
    ((Control) this).MaximumSize = new Size(int.MaxValue, ((Form) this).Size.Height);
    Size size2 = ((Form) this).Size;
    int width2 = size2.Width;
    size2 = ((Form) this).Size;
    int height2 = size2.Height;
    ((Control) this).MinimumSize = new Size(width2, height2);
    ((Form) this).StartPosition = FormStartPosition.CenterScreen;
    if (this.RobotControls.Count > 0)
    {
      this.RobotControls[0].Select();
    }
    else
    {
      if (this.OperationControls.Count <= 0)
        return;
      this.OperationControls[0].Select();
    }
  }

  private void UpdateOperationControls()
  {
    foreach (Control operationControl in this.OperationControls)
    {
      bool flag = true;
      List<string> stringList = new List<string>();
      TxRoboticParam txRoboticParam = (TxRoboticParam) null;
      for (int index = 0; index < this.m_operations.Count; ++index)
      {
        txRoboticParam = this.m_operations[index].GetParameter(operationControl.Name);
        if (txRoboticParam != null)
        {
          string str = this.ParamToString(txRoboticParam);
          if (!stringList.Contains(str) && str != "")
            stringList.Add(str);
        }
        else
          flag = false;
      }
      if (stringList.Count == 1 & flag)
      {
        switch (operationControl)
        {
          case TextBox _ when txRoboticParam is TxRoboticStringParam:
            (operationControl as TextBox).Text = (txRoboticParam as TxRoboticStringParam).Value;
            continue;
          case ComboBox _ when txRoboticParam is TxRoboticStringParam:
            (operationControl as ComboBox).Text = (txRoboticParam as TxRoboticStringParam).Value;
            continue;
          case TxNumericEditBoxCtrl _ when txRoboticParam is TxRoboticIntParam:
            (operationControl as TxNumericEditBoxCtrl).Value = (double) (txRoboticParam as TxRoboticIntParam).Value;
            continue;
          case TxNumericEditBoxCtrl _ when txRoboticParam is TxRoboticDoubleParam:
            (operationControl as TxNumericEditBoxCtrl).Value = (txRoboticParam as TxRoboticDoubleParam).Value;
            continue;
          default:
            continue;
        }
      }
    }
  }

  private string ParamToString(TxRoboticParam param)
  {
    string str = "";
    switch (param)
    {
      case TxRoboticStringParam _:
        str = (param as TxRoboticStringParam).Value;
        break;
      case TxRoboticIntParam _:
        str = (param as TxRoboticIntParam).Value.ToString();
        break;
      case TxRoboticDoubleParam _:
        str = (param as TxRoboticDoubleParam).Value.ToString();
        break;
    }
    return str;
  }

  private void UpdateRobotControls()
  {
    foreach (Control robotControl in this.RobotControls)
    {
      TxRoboticParam instanceParameter = this.m_robot.GetInstanceParameter(robotControl.Name);
      if (instanceParameter != null)
      {
        switch (robotControl)
        {
          case TextBox _ when instanceParameter is TxRoboticStringParam:
            (robotControl as TextBox).Text = (instanceParameter as TxRoboticStringParam).Value;
            continue;
          case ComboBox _ when instanceParameter is TxRoboticStringParam:
            (robotControl as ComboBox).Text = (instanceParameter as TxRoboticStringParam).Value;
            continue;
          case TxNumericEditBoxCtrl _ when instanceParameter is TxRoboticIntParam:
            (robotControl as TxNumericEditBoxCtrl).Value = (double) (instanceParameter as TxRoboticIntParam).Value;
            continue;
          case TxNumericEditBoxCtrl _ when instanceParameter is TxRoboticDoubleParam:
            (robotControl as TxNumericEditBoxCtrl).Value = (instanceParameter as TxRoboticDoubleParam).Value;
            continue;
          default:
            continue;
        }
      }
    }
  }

  private void AddGroupToDialog(
    string name,
    List<Control> controls,
    int tabIndex,
    ref int maxLableWidth)
  {
    int num1 = 6;
    int y = 20;
    GroupBox groupBox = new GroupBox();
    groupBox.Text = name;
    groupBox.TabIndex = tabIndex++;
    for (int index = 0; index < controls.Count; ++index)
    {
      Label label = new Label();
      label.Text = controls[index].Name + ":";
      label.AutoSize = true;
      ((Control) this).Controls.Add((Control) label);
      if (label.Width > maxLableWidth)
        maxLableWidth = label.Width;
      ((Control) this).Controls.Remove((Control) label);
    }
    for (int index = 0; index < controls.Count; ++index)
    {
      Label label1 = new Label();
      label1.Text = controls[index].Name + ":";
      label1.AutoSize = true;
      label1.Location = new Point(4, y + 3);
      ((Control) this).Controls.Add((Control) label1);
      groupBox.Controls.Add((Control) label1);
      if (controls[index] is TxNumericEditBoxCtrl)
      {
        TxNumericEditBoxCtrl control = controls[index] as TxNumericEditBoxCtrl;
        ToolTip toolTip = new ToolTip();
        Label label2 = label1;
        string[] strArray = new string[5]
        {
          "[",
          null,
          null,
          null,
          null
        };
        double num2 = control.LowerBound;
        strArray[1] = num2.ToString();
        strArray[2] = " - ";
        num2 = control.UpperBound;
        strArray[3] = num2.ToString();
        strArray[4] = "]";
        string caption = string.Concat(strArray);
        toolTip.SetToolTip((Control) label2, caption);
      }
      controls[index].Location = new Point(maxLableWidth + 10, y);
      controls[index].TabIndex = tabIndex++;
      y = y + controls[index].Height + num1;
      groupBox.Controls.Add(controls[index]);
    }
    if (groupBox == null)
      return;
    groupBox.Height = y - num1 + 8;
    groupBox.Location = new Point(12, this.m_realY);
    this.m_realY += groupBox.Height;
    this.m_realY += 4;
    ((Control) this).Controls.Add((Control) groupBox);
  }

  private void InitTemplateCombo()
  {
    bool flag1 = true;
    this.TemplateCombo.Items.Add((object) "");
    TxObjectList items = TxApplication.ActiveSelection.GetItems();
    List<string> stringList1 = new List<string>();
    List<string> stringList2 = new List<string>();
    List<string> stringList3;
    if (((Collection<ITxObject>) items)[0] is TxRobot)
    {
      this.Copy_button.Visible = false;
      stringList3 = this.m_templateServices.GetAvailableRobotTemplates();
      TxRoboticParam instanceParameter = this.m_robot.GetInstanceParameter("OLP_XML_DOWNLOAD_TEMPLATE");
      if (instanceParameter != null && instanceParameter is TxRoboticStringParam)
      {
        string str = (instanceParameter as TxRoboticStringParam).Value;
        stringList2.Add(str);
      }
    }
    else
    {
      foreach (object obj in (Collection<ITxObject>) items)
        this.m_operations.Add(obj as ITxRoboticOperation);
      TxOlpControllerUtilities controllerUtilities = new TxOlpControllerUtilities();
      stringList3 = this.m_templateServices.GetAvailableOperationTemplates();
      bool flag2 = false;
      string str1 = "";
      foreach (object obj in (Collection<ITxObject>) items)
      {
        TxRoboticParam parameter = (obj as ITxRoboticOperation).GetParameter("OLP_XML_DOWNLOAD_TEMPLATE");
        if (parameter != null && parameter is TxRoboticStringParam)
        {
          string str2 = (parameter as TxRoboticStringParam).Value;
          if (!stringList2.Contains(str2))
            stringList2.Add(str2);
        }
        else
          flag1 = false;
      }
      if (flag2)
      {
        int num = (int) TxMessageBox.Show(str1, CApSetTemplateAndKeywordsStringTable.CMD_NAME, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
      }
    }
    foreach (object obj in stringList3)
      this.TemplateCombo.Items.Add(obj);
    foreach (string str in stringList2)
    {
      if (!stringList3.Contains(str))
        this.TemplateCombo.Items.Add((object) str);
    }
    if (!(stringList2.Count == 1 & flag1))
      return;
    this.TemplateCombo.SelectedItem = (object) stringList2[0];
    this.TemplateCombo.SelectedText = stringList2[0];
    this.m_templateName = stringList2[0];
  }

  private void InitRobot()
  {
    TxObjectList items = TxApplication.ActiveSelection.GetItems();
    if (((Collection<ITxObject>) items)[0] is TxRobot)
      this.m_robot = ((Collection<ITxObject>) items)[0] as TxRobot;
    else
      this.m_robot = new TxOlpControllerUtilities().GetRobot(((Collection<ITxObject>) items)[0] as ITxOperation);
  }

  private bool InitDownloadTemplateServices()
  {
    bool flag = true;
    try
    {
      try
      {
        TxOlpMotionCommandServices motionCommandServices = new TxOlpMotionCommandServices(this.m_robot);
      }
      catch (TxOlpXMLMissingOlpConfigurationFileException ex)
      {
      }
      this.m_templateServices = new TxOlpDownloadTemplateServices((ITxRobotController) this.m_robot.Controller);
      if (this.m_templateServices.GetAvailableOperationTemplates().Count == 0)
        flag = false;
    }
    catch
    {
      flag = false;
    }
    return flag;
  }

  private void OpenCustomizedCommandXMLCheckerCmd()
  {
    if (TxMessageBox.Show(CApSetTemplateAndKeywordsStringTable.XML_Error, CApSetTemplateAndKeywordsStringTable.CMD_NAME, MessageBoxButtons.YesNo, MessageBoxIcon.Hand) == DialogResult.Yes)
    {
      if (TxCommandLicenser.CustomizedUILicense)
      {
        new TxCommandManager().ExecuteCommandByCommandProgId("CUICustomizedCommandXMLCheckerCmd", (object) this.m_robot, false);
      }
      else
      {
        int num = (int) TxMessageBox.Show(CApSetTemplateAndKeywordsStringTable.NoLicenseForChecker, CApSetTemplateAndKeywordsStringTable.CMD_NAME, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
      }
    }
    ((Form) this).Close();
  }

  private void AddDelegateToControls(List<Control> ControlList)
  {
    foreach (Control control in ControlList)
    {
      control.Leave += new EventHandler(this.control_Leave);
      control.Enter += new EventHandler(this.control_Enter);
      switch (control)
      {
        case TxObjComboBoxCtrl _:
          ((TxObjComboBoxCtrl) control).Picked += new TxObjComboBoxCtrl_PickedEventHandler(this.txObjComboBoxCtrl_Picked);
          ((TxObjComboBoxCtrl) control).SelectionChanged += new EventHandler(this.txObjComboBoxCtrl_SelectionChanged);
          continue;
        case TxObjEditBoxCtrl _:
          ((TxObjEditBoxCtrl) control).Picked += new TxObjEditBoxCtrl_PickedEventHandler(this.txObjEditBoxCtrl_Picked);
          continue;
        case TextBox _:
          control.TextChanged += new EventHandler(this.textBox_TextChanged);
          continue;
        case ComboBox _:
          ((ComboBox) control).SelectedIndexChanged += new EventHandler(this.comboBoxCtrl_SelectedIndexChanged);
          continue;
        case TxNumericEditBoxCtrl _:
          control.KeyUp += new KeyEventHandler(this.txNumericEditBoxCtrl_KeyChanged);
          continue;
        default:
          continue;
      }
    }
  }

  private void CheckRequiredDialogFields()
  {
    bool flag = false;
    foreach (Control robotControl in this.RobotControls)
    {
      if (robotControl.Text == "")
      {
        flag = true;
        break;
      }
    }
    if (!flag)
    {
      foreach (Control operationControl in this.OperationControls)
      {
        if (operationControl.Text == "")
        {
          flag = true;
          break;
        }
      }
    }
    if (flag)
      this.OKButtonCtrl.Enabled = false;
    else
      this.OKButtonCtrl.Enabled = true;
  }

  private void InitSizes()
  {
    this.m_maxRobotLabelWidth = 0;
    this.m_maxOperationLabelWidth = 0;
    this.m_realY = 38;
    ((Form) this).Size = new Size(314, 111);
  }

  protected virtual void Dispose(bool disposing)
  {
    if (disposing && this.components != null)
      this.components.Dispose();
    base.Dispose(disposing);
  }

  private void InitializeComponent()
  {
    ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof (CUISetTemplateAndKeywordsDialog));
    this.Copy_button = new Button();
    this.OKButtonCtrl = new Button();
    this.Close_button = new Button();
    this.label1 = new Label();
    this.TemplateCombo = new ComboBox();
    ((Control) this).SuspendLayout();
    this.Copy_button.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
    this.Copy_button.Location = new Point(12, 41);
    this.Copy_button.Name = "Copy_button";
    this.Copy_button.Size = new Size(78, 20);
    this.Copy_button.TabIndex = 90;
    this.Copy_button.Text = "Copy From...";
    this.Copy_button.UseVisualStyleBackColor = true;
    this.Copy_button.Click += new EventHandler(this.Copy_button_Click);
    this.OKButtonCtrl.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
    this.OKButtonCtrl.Location = new Point(130, 41);
    this.OKButtonCtrl.Name = "OKButtonCtrl";
    this.OKButtonCtrl.Size = new Size(75, 20);
    this.OKButtonCtrl.TabIndex = 91;
    this.OKButtonCtrl.Text = "OK";
    this.OKButtonCtrl.UseVisualStyleBackColor = true;
    this.OKButtonCtrl.Click += new EventHandler(this.OK_button_Click);
    this.Close_button.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
    this.Close_button.Location = new Point(211, 41);
    this.Close_button.Name = "Close_button";
    this.Close_button.Size = new Size(75, 20);
    this.Close_button.TabIndex = 92;
    this.Close_button.Text = "Cancel";
    this.Close_button.UseVisualStyleBackColor = true;
    this.Close_button.Click += new EventHandler(this.Close_button_Click);
    this.label1.AutoSize = true;
    this.label1.Location = new Point(12, 15);
    this.label1.Name = "label1";
    this.label1.Size = new Size(54, 13);
    this.label1.TabIndex = 1;
    this.label1.Text = "Template:";
    this.TemplateCombo.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
    this.TemplateCombo.DropDownStyle = ComboBoxStyle.DropDownList;
    this.TemplateCombo.FormattingEnabled = true;
    this.TemplateCombo.Location = new Point(72, 12);
    this.TemplateCombo.Name = "TemplateCombo";
    this.TemplateCombo.Size = new Size(214, 21);
    this.TemplateCombo.TabIndex = 2;
    this.TemplateCombo.SelectedValueChanged += new EventHandler(this.TemplateCombo_SelectedValueChanged);
    ((ContainerControl) this).AutoScaleDimensions = new SizeF(6f, 13f);
    ((ContainerControl) this).AutoScaleMode = AutoScaleMode.Font;
    ((Form) this).ClientSize = new Size(298, 73);
    ((Control) this).Controls.Add((Control) this.TemplateCombo);
    ((Control) this).Controls.Add((Control) this.label1);
    ((Control) this).Controls.Add((Control) this.Close_button);
    ((Control) this).Controls.Add((Control) this.OKButtonCtrl);
    ((Control) this).Controls.Add((Control) this.Copy_button);
    ((Form) this).Icon = (Icon) componentResourceManager.GetObject("$this.Icon");
    ((Form) this).MaximizeBox = false;
    ((Form) this).MinimizeBox = false;
    ((Control) this).Name = nameof (CUISetTemplateAndKeywordsDialog);
    this.ShouldCloseOnDocumentUnloading = true;
    ((Form) this).SizeGripStyle = SizeGripStyle.Hide;
    ((Control) this).Text = "Set Template and Keywords";
    ((Form) this).Activated += new EventHandler(this.CUISetTemplateAndKeywordsDialog_Activated);
    ((Control) this).Resize += new EventHandler(this.CUISetTemplateAndKeywordsDialog_Resize);
    ((Control) this).ResumeLayout(false);
    ((Control) this).PerformLayout();
  }
}
